/**
 * 商家模块js
 **/

 $(function(){

 	// 显示全部优惠券
 	var $feeTypesEl = $('.j-fee-types');
 	var $feeListEl  = $feeTypesEl.find('.j-fee-list');
 	$feeTypesEl.bind('click', '.j-toggle-btn', function(ev){
 		ev.preventDefault();
 		$feeListEl
 				.animate({height: $feeListEl.children().length * $feeListEl.children().outerHeight() + 'px'}, 200);
 	});

 	// 分享组件
	var spage = 1;
 	var $shareEl = $('.j-share');
 	var $shareListEl = $('.j-share-list');
 	$shareEl.bind('click', '.j-more-btn', function(ev){
 		ev.preventDefault();
 		var $btn = $(this);
 		$btn.text('加载中...');
		$.ajax({
			url: PINER.root + '/?m=item&a=ajax_list',
			data: {sp: spage},
			type: 'GET',
			dataType: 'json',
			success: function(result){
				if(result.status == 1){
					var html = result.data.html;
					$shareListEl.append(html);
					$btn.text('查看更多分享>');
					spage += 1; //页码加1
				}else{
					$.pinphp.tip({content:result.msg, icon:'error'});
				}
			}
		});
 	})
 })